home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3.iso
/
chapte21
/
ex5.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-29
|
3KB
|
56 lines
#include <genstub.c>
#define LISTBOX_ID 1000
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE: // Create list box child window to show section keys.
{
RECT rectClient;
LRESULT lRetVal = DefWindowProc(hWnd, uMsg, wParam, lParam);
GetClientRect( hWnd, &rectClient ); // Use client rectangle to center child.
CreateWindow( "listbox", // listbox class
"child listbox", // name
WS_CHILD | WS_VISIBLE | LBS_STANDARD, // style
10, 10, // location
rectClient.right - rectClient.left - 20, // width
rectClient.bottom - rectClient.top - 20, // height
hWnd, // parent
(HMENU) LISTBOX_ID, // child window ID
hInst, // app instance
NULL ); // special parameters
return lRetVal;
}
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{
LPTSTR lpTemp = GetEnvironmentStrings( );
HWND hWndListBox = GetDlgItem( hWnd, LISTBOX_ID );
if ( hWndListBox )
{
SendMessage( hWndListBox, LB_RESETCONTENT, 0, 0 );
while ( *lpTemp )
{
SendMessage( hWndListBox, LB_ADDSTRING, 0, (LPARAM) lpTemp );
lpTemp += lstrlen(lpTemp) + 1; // jump past null
}
}
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return( NULL );
}